<?php

namespace App\Models\Log;

use App\Models\Conf\Site;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;

class SiteDeposit extends Model
{
    //确认中
    const STATUS_CONFIRMING = 0;
    //支付完成
    const STATUS_SUCCESS = 1;
    //支付失败
    const STATUS_FAIL = -1;

    //阿里支付方式
    const PAY_ALI_PAY = 1;
    //微信支付
    const PAY_WX_PAY = 2;
    //银行卡支付
    const PAY_BANK_PAY = 3;

    public $table = 'log_site_deposit';

    protected $guarded = [];


    public function site()
    {
        return $this->belongsTo(Site::class, 'site_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function getStatus()
    {
        switch ($this->pay_status) {
            case self::STATUS_FAIL:
                return '支付失败';
            case self::STATUS_CONFIRMING:
                return '待确认';
            case self::STATUS_SUCCESS:
                return '支付成功';
        }
    }

    public function getPayType()
    {
        switch ($this->pay_type) {
            case self::PAY_ALI_PAY:
                return '支付宝支付';
            case self::PAY_WX_PAY:
                return '微信支付';
            case self::PAY_BANK_PAY:
                return '银行卡支付';
        }
    }
}
